home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / sem.h.z / sem.h
C/C++ Source or Header  |  1992-04-03  |  4KB  |  166 lines

  1. #ifndef __SYS_SEM_H__
  2. #define __SYS_SEM_H__
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. /*
  9.  * Copyright 1990, Silicon Graphics, Inc. 
  10.  * All Rights Reserved.
  11.  *
  12.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  13.  * the contents of this file may not be disclosed to third parties, copied or 
  14.  * duplicated in any form, in whole or in part, without the prior written 
  15.  * permission of Silicon Graphics, Inc.
  16.  *
  17.  * RESTRICTED RIGHTS LEGEND:
  18.  * Use, duplication or disclosure by the Government is subject to restrictions 
  19.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  20.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or 
  21.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 
  22.  * rights reserved under the Copyright Laws of the United States.
  23.  */
  24. /*    Copyright (c) 1984 AT&T    */
  25. /*      All Rights Reserved      */
  26.  
  27. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  28. /*    The copyright notice above does not evidence any       */
  29. /*    actual or intended publication of such source code.    */
  30.  
  31. #ident    "$Revision: 3.15 $"
  32.  
  33. /*
  34. **    IPC Semaphore Facility.
  35. */
  36.  
  37. /*
  38. **    Implementation Constants.
  39. */
  40. #ifdef _KERNEL
  41. #define    PSEMN    (PZERO + 3)    /* sleep priority waiting for greater value */
  42. #define    PSEMZ    (PZERO + 2)    /* sleep priority waiting for zero */
  43. #endif /* _KERNEL */
  44.  
  45. /*
  46. **    Permission Definitions.
  47. */
  48.  
  49. #define    SEM_A    0200    /* alter permission */
  50. #define    SEM_R    0400    /* read permission */
  51.  
  52. /*
  53. **    Semaphore Operation Flags.
  54. */
  55.  
  56. #define    SEM_UNDO    010000    /* set up adjust on exit entry */
  57.  
  58. /*
  59. **    Semctl Command Definitions.
  60. */
  61.  
  62. #define    GETNCNT    3    /* get semncnt */
  63. #define    GETPID    4    /* get sempid */
  64. #define    GETVAL    5    /* get semval */
  65. #define    GETALL    6    /* get all semval's */
  66. #define    GETZCNT    7    /* get semzcnt */
  67. #define    SETVAL    8    /* set semval */
  68. #define    SETALL    9    /* set all semval's */
  69.  
  70. /*
  71. **    Structure Definitions.
  72. */
  73.  
  74. /*
  75. **    There is one semaphore id data structure for each set of semaphores
  76. **        in the system.
  77. */
  78.  
  79. struct semid_ds {
  80.     struct ipc_perm    sem_perm;    /* operation permission struct */
  81.     struct sem    *sem_base;    /* ptr to first semaphore in set */
  82.     ushort        sem_nsems;    /* # of semaphores in set */
  83.     time_t        sem_otime;    /* last semop time */
  84.     time_t        sem_ctime;    /* last change time */
  85. };
  86.  
  87. #ifdef _KERNEL
  88. /*
  89. **    There is one semaphore structure for each semaphore in the system.
  90. */
  91.  
  92. struct sem {
  93.     ushort    semval;        /* semaphore text map address */
  94.     sema_t    semnwait;    /* to wait for non-zero value */
  95.     sema_t    semzwait;    /* to wait for zero value */
  96.     short    sempid;        /* pid of last operation */
  97.     short    semncnt;    /* # awaiting semval > cval */
  98.     short    semzcnt;    /* # awaiting semval = 0 */
  99. };
  100.  
  101. /*
  102. **    There is one undo structure per process in the system.
  103. */
  104.  
  105. struct sem_undo {
  106.     struct sem_undo    *un_np;    /* ptr to next active undo structure */
  107.     short        un_cnt;    /* # of active entries */
  108.     struct undo {
  109.         short    un_aoe;    /* adjust on exit values */
  110.         short    un_num;    /* semaphore # */
  111.         int    un_id;    /* semid */
  112.     }    un_ent[1];    /* undo entries (one minimum) */
  113. };
  114.  
  115. /*
  116.  *    Macro to generate sem id lock ptr
  117.  */
  118.  
  119. #define    SEMADDR(X)    &semsem[X]
  120. #endif /* _KERNEL */
  121.  
  122. /*
  123. ** semaphore information structure
  124. */
  125. struct    seminfo    {
  126.     int    semmni,        /* # of semaphore identifiers */
  127.         semmns,        /* # of semaphores in system */
  128.         semmnu,        /* # of undo structures in system */
  129.         semmsl,        /* max # of semaphores per id */
  130.         semopm,        /* max # of operations per semop call */
  131.         semume,        /* max # of undo entries per process */
  132.         semusz,        /* size in bytes of undo structure */
  133.         semvmx,        /* semaphore maximum value */
  134.         semaem;        /* adjust on exit max value */
  135. };
  136.  
  137. /*
  138. **    User semaphore template for semop system calls.
  139. */
  140.  
  141. struct sembuf {
  142.     ushort    sem_num;    /* semaphore # */
  143.     short    sem_op;        /* semaphore operation */
  144.     short    sem_flg;    /* operation flags */
  145. };
  146.  
  147.  
  148. union semun {
  149.         int val;
  150.         struct semid_ds *buf;
  151.         ushort *array;
  152. };
  153.  
  154. #ifndef _KERNEL
  155. extern int     semctl (int, int, int, ...);
  156. extern int    semget (key_t, int, int);
  157. extern int    semop  (int, struct sembuf *, unsigned);
  158. #endif
  159.  
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163.  
  164. #endif /* !__SYS_SEM_H__ */
  165.  
  166.